package com.treeman.api.json.user;

import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import com.treeman.user.User;
import com.treeman.user.UserRole;

public class UserJson {

	private String username;

	private String email;

	private String firstname;

	private String lastname;

	private Date bornDate;

	private Date created;

	private Date lastLogin;

	private Set<String> roles = new HashSet<String>();

	public UserJson() {
	}

	public UserJson(User user) {
		this.username = user.getUsername();
		this.email = user.getEmail();
		this.created = user.getCreatedDate();
		this.lastLogin = user.getLastLoginDate();

		for (UserRole role : user.getUserRoles()) {
			this.roles.add(role.getRole().toString());
		}

		this.firstname = user.getUserAdditionalInformations().getFirstName();
		this.lastname = user.getUserAdditionalInformations().getLastName();
		this.bornDate = user.getUserAdditionalInformations().getBirthday();
	}

	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public Date getCreated() {
		return created;
	}

	public void setCreated(Date created) {
		this.created = created;
	}

	public Date getLastLogin() {
		return lastLogin;
	}

	public void setLastLogin(Date lastLogin) {
		this.lastLogin = lastLogin;
	}

	public Set<String> getRoles() {
		return roles;
	}

	public void setRoles(Set<String> roles) {
		this.roles = roles;
	}

	public String getFirstname() {
		return firstname;
	}

	public void setFirstname(String firstname) {
		this.firstname = firstname;
	}

	public String getLastname() {
		return lastname;
	}

	public void setLastname(String lastname) {
		this.lastname = lastname;
	}

	public Date getBornDate() {
		return bornDate;
	}

	public void setBornDate(Date bornDate) {
		this.bornDate = bornDate;
	}
}
